<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title></title>
	
	<script type="text/javascript" src="http://127.0.0.1/c45_classCode/Static/uploadify/jquery-1.8.2.min.js"></script>
	<script type="text/javascript" src="http://127.0.0.1/c45_classCode/Static/uploadify/jquery.uploadify.min.js"></script>
	<link href="http://127.0.0.1/c45_classCode/Static/uploadify/uploadify.css" type="text/css" rel="stylesheet"></link>
	<script type="text/javascript" charset="utf-8" src="http://127.0.0.1/c45_classCode/Static/ueditor1_4_3/ueditor.config.js"></script>
	    <script type="text/javascript" charset="utf-8" src="http://127.0.0.1/c45_classCode/Static/ueditor1_4_3/ueditor.all.min.js"> </script>
	    <script type="text/javascript" charset="utf-8" src="http://127.0.0.1/c45_classCode/Static/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
	<link type="text/css" rel="stylesheet" href="http://127.0.0.1/c45_classCode/Static/hdjs/hdjs.css"/>
	<script type="text/javascript" src="http://127.0.0.1/c45_classCode/Static/hdjs/hdjs.min.js"></script>
	<script type="text/javascript" src="http://127.0.0.1/c45_classCode/Static/cal/lhgcalendar.min.js"></script>
	<style type="text/css">
		.liImg{
			width:80px;
			position: relative;
		}
		.closeBtn{
			width:15px;
			height: 15px;
			line-height: 15px;
			text-align: center;
			background: #FFF;
			cursor: pointer;
			position: absolute;
			top:0px;
			right: 0px;
		}
		.closeBtn:hover{
			background: #ccc;
		}
	</style>
</head>
<body>
	<div class="hd-menu-list">
	    <ul>
	        <li><a href="<?php echo U('Article/index');?>">文章列表</a></li>
	        <li class="active"><a href="<?php echo U('Article/add');?>">添加文章</a></li>
	    </ul>
	</div>

	<form action="" method="post">
		
		<div class="hd-tab">
		    <ul class="hd-tab-menu">
		        <li lab="base" class="active">
		            <a> 基本设置 </a>
		        </li>
		        <li lab="content">
		            <a>内容 </a>
		        </li>
		        <li lab="thumb">
		            <a>缩略图 </a>
		        </li>
		    </ul>
		    <div class="hd-tab-content">
		        <div lab="base" class="hd-tab-area">
		            <table class="hd-form hd-table hd-table-form">
		                <tbody><tr>
		                    <th class="hd-w100">标题</th>
		                    <td>
		                        <input name="title" type="text" value="<?php echo $data['title'];?>">
		                    </td>
		                </tr>
		                <tr>
		                    <th>所属栏目</th>
		                    <td>
		                       <select name="cid" id="">
		                       		<?php foreach ($category as $k=>$c){?>
			                       		<option value="<?php echo $c['cid'];?>"
			                       		    <?php if($c['cid']==$data['cid']){ ?>selected=""<?php } ?> ><?php echo $c['_name'];?></option>
			                       	<?php }?>
		                       </select>	
		                    </td>
		                </tr>
		                <tr>
		                    <th>文章标签</th>
		                    <td>
		                    	        <?php
        //初始化
        $hd['list']['t'] = array(
            'first' => false,
            'last'  => false,
            'total' => 0,
            'index' => 0
        );
        if (empty($tags)) {
            echo '';
        } else {
            $listId = 0;
            $listShowNum=0;
            $listNextId=0;
            foreach ($tags as $t) {
                //开始值
                if ($listId<0) {
                    $listId++;
                    continue;
                }
                //步长
                if($listId!=$listNextId){$listId++;continue;}
                //显示条数
                if($listShowNum>=100)break;
                //第几个值
                $hd['list'][t]['index']++;
                //第1个值
                $hd['list'][t]['first']=($listId == 0);
                //最后一个值
                $hd['list'][t]['last']= (count($tags)-1 <= $listId);
                //总数
                $hd['list'][t]['total']++;
                //增加数
                $listId++;
                $listShowNum++;
                $listNextId+=1
                ?>
			                       <input type="checkbox" name="tid[]" value="<?php echo $t['tid'];?>"     <?php if(in_array($t['tid'],$data['tids'])){ ?>checked=""<?php } ?> > <?php echo $t['tname'];?> &emsp;
			                   <?php }}?>
		                    </td>
		                </tr>
		                <tr>
		                    <th>作者</th>
		                    <td>
		                        <input name="author" type="text">
		                    </td>
		                </tr>
		                <tr>
		                    <th>摘要</th>
		                    <td>
		                        <input name="digest" type="text">
		                    </td>
		                </tr>
		                <tr>
		                    <th>关键字</th>
		                    <td>
		                        <input name="keyword" type="text">
		                    </td>
		                </tr>
		                <tr>
		                    <th>添加时间</th>
		                    <td>
		                        <input readonly="readonly" id="sendtime" name="sendtime" value="<?php echo date('Y/m/d H:i:s',$data['sendtime']);?>" class="hd-w150" type="text">
								<script>
								    $(function () {
								        $('#sendtime').calendar({format: 'yyyy/MM/dd HH:mm:ss'});
								    })
								</script>
		                    </td>
		                </tr>
		            </tbody></table>
		        </div>
		        <div lab="content" class="hd-tab-area">
		        	<table class="hd-form hd-table hd-table-form">
			        	<tr>
		                    <th>描述</th>
		                    <td>
		                    	<textarea name="description" id="" class="hd-w300 hd-h100" cols="30" rows="10"></textarea>
		                    </td>
		                </tr>
			            <tr>
		                    <th>内容</th>
		                    <td>
		                    	<script id="editor" name="content" type="text/plain" style="width:600px;height:300px;"><?php echo $data['content'];?></script>
							    <script>
							        var ue = UE.getEditor('editor');
							    </script>
		                    </td>
		                </tr>
	                </table>
		        </div>
		        <div lab="thumb" class="hd-tab-area">
		        	<table class="hd-form hd-table hd-table-form">
			        	<tr>
		                    <th>缩略图</th>
		                    <td>
		                    	<div lab="uploadFile">
						            <input id="file" type="file" multiple="true">
						            <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
						            <script type="text/javascript">
						                $(function() {
						                    $('#file').uploadify({
						                        'formData'     : {//POST数据
						                            '<?php echo session_name();?>' : '<?php echo session_id();?>',
						                        },
						                        'fileTypeDesc' : '上传文件',//上传描述
						                        'fileTypeExts' : '<?php echo $set['filetype'];?>',
						                        'swf'      : 'http://127.0.0.1/c45_classCode/Static/uploadify/uploadify.swf',
						                        'uploader' : '<?php echo U("Flink/upload");?>',
						                        'buttonText':'选择文件',
						                        'fileSizeLimit' : '2000KB',
						                        'uploadLimit' : 1000,//上传文件数
						                        'width':65,
						                        'height':25,
						                        'successTimeout':10,//等待服务器响应时间
						                        'removeTimeout' : 0.2,//成功显示时间
						                        'onUploadSuccess' : function(file, data, response) {
						                            data=$.parseJSON(data);
						                            var imageUrl = data.image?data.url:'http://127.0.0.1/c45_classCode/Static/image/default.png';
						                            var li="<li class='liImg' path='"+data.path+"' url='"+data.url+"'><img src='"+imageUrl+"' class='hd-w80 hd-h70'/><input type='hidden' name='thumb' value='"+data.path+"'/><div class='closeBtn'>X</div></li>";
						                            $("#uploadList ul").prepend(li);
						                        }
						                    });
						                });

						            </script>
						            <div id="uploadList">
						                <ul>
						 					    <?php if(!empty($data['thumb'])){ ?>
						 						<li class='liImg' path='<?php echo $data['thumb'];?>' url='<?php echo $data['thumb'];?>'><img src='http://127.0.0.1/c45_classCode/<?php echo $data["thumb"];?>' class='hd-w80 hd-h70'/><input type='hidden' name='thumb' value='<?php echo $data['thumb'];?>'/><div class='closeBtn'>X</div></li>
						 					<?php } ?>
						                </ul>
						            </div>
						            <script type="text/javascript">
						            	$(function(){
						            		$('.closeBtn').live('click',function(){
						            			oLi = $(this).parents('li').eq(0);
						            			path = oLi.attr('path');
						            			$.ajax({
						            				url:'<?php echo U("Flink/delPic");?>',
						            				data:{path:path},
						            				type:'post',
						            				dataType:'json',
						            				success:function(data){
						            					if(data.status==1){
						            						oLi.remove();
						            					}
						            				}
						            			})
						            		})
						            	})
						            </script>	
						        </div>
		                    </td>
		                </tr>
			            
	                </table>
		        </div>
		    </div>
		</div>

		<input type="submit" value="保存" class="hd-btn"><input type="hidden" name="aid" value="<?php echo $hd['get']['aid'];?>">
	</form>
</body>
</html>